/*
* 测试UserDao
*
*
* */

import jk.UserDao;
import jk.UserDao2;
import jk.UserDao3;
import org.junit.Test;
import user.Users;

import javax.print.attribute.standard.JobOriginatingUserName;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class UserDaotest {
    UserDao ts=new UserDao();
    UserDao2 ts1=new UserDao2();
    UserDao3 ts2=new UserDao3();
    Users us1=new Users();
    //测试insert方法
    @Test
    public void insertest() throws SQLException, ClassNotFoundException {
        us1.setUsername("二傻子");
        us1.setPassword("12345678");
        ts2.insert(us1);
    }
    //测试update
    @Test
    public void updatetest() throws SQLException, ClassNotFoundException {
        us1.setUsername("木子李");
        us1.setPassword("12345678");
        ts2.update(us1);
    }
    //测试delete
    @Test
    public void deletetest() throws SQLException, ClassNotFoundException {
        us1.setUsername("aaa");
        ts2.delete(us1);
    }
    //测试result
    @Test
    public void resultest() throws SQLException, ClassNotFoundException {
        ResultSet rs=ts.result("aaa","111111");
        while (rs.next()) {
            System.out.print(rs.getInt("ID")
                    +" "+rs.getString("USERNAME")
                    +" "+rs.getString("PASSWORD")
                    +" "+rs.getInt("STATE"));
        }
        ts.close();
    }
    @Test
    public void result2test() throws SQLException, ClassNotFoundException {
        List<Users> user=ts2.result();
        System.out.println(user);
    }
    @Test
    public void chaxun() throws SQLException, ClassNotFoundException {
        us1.setUsername("cjj");
        us1.setPassword("123456");
        ResultSet rs=ts2.selectbyusernameanpassword(us1);
        while (rs.next()){
            System.out.println("账号存在");
        }

    }
}

